package com.waypolice.manager.controller;

import com.baidu.unbiz.fluentvalidator.ComplexResult;
import com.baidu.unbiz.fluentvalidator.FluentValidator;
import com.baidu.unbiz.fluentvalidator.ResultCollectors;
import com.waypolice.base.BaseController;
import com.waypolice.common.pojo.TaotaoResult;
import com.waypolice.common.pojo.UpmsResult;
import com.waypolice.common.pojo.UpmsResultConstant;
import com.waypolice.common.utils.StringUtil;
import com.waypolice.common.validator.LengthValidator;
import com.waypolice.manager.service.SearchSetService;
import com.waypolice.manager.service.UpmsDictionaryService;
import com.waypolice.pojo.UpmsDictionary;
import com.waypolice.pojo.UpmsDictionaryExample;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 数据字典controller
 * Created by lzh on 2019/3/12.
 */
@Controller
@Api(value = "数据字典--检索设置", description = "数据字典--检索设置")
@RequestMapping("/pcwindow")
public class SearchSetController extends BaseController {

    private static final Logger LOGGER = LoggerFactory.getLogger(SearchSetController.class);

    @Autowired
    public UpmsDictionaryService upmsDictionaryService;
    @Autowired
    public SearchSetService searchSetService;


    @ApiOperation(value = "检索设置")
    @RequiresPermissions("upms:search:read")
    @RequestMapping(value = "/toSetSearchRange", method = RequestMethod.GET)
    public String index() {
        return "/manage/searchSet/searchSet";
    }
    /**
     * 查询全部保存期限
     * @param response
     * @param request
     * @return
     */
    @ApiOperation(value = "查询检索范围")
    @RequestMapping(value = "/findAllSearchScopeAction")
    @ResponseBody
    public Object findAllSearchScope(HttpServletResponse response, HttpServletRequest request) {
        List<UpmsDictionary> types = upmsDictionaryService.findAllSearchScope();
        Map<String, Object> result = new HashMap<>(2);
        result.put("rows",types);
        return result;
    }
    /**
     * 查询全部保存期限
     * @param response
     * @param request
     * @return
     */
    @ApiOperation(value = "重置检索范围")
    @RequestMapping(value = "/searchScopeCleanAction")
    @ResponseBody
    public TaotaoResult searchScopeClean(HttpServletResponse response, HttpServletRequest request) {
        String chooseSet = request.getParameter("chooseSet");
        TaotaoResult result = new TaotaoResult();
        result = searchSetService.searchScopeClean(chooseSet);
        return result;
    }
}